package com.myrslok.set;

import com.sun.tools.internal.xjc.api.S2JJAXBModel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.File;

public class FileResourceSet extends ResourceSet<File> {

    private final File baseDir;

    public FileResourceSet(@Nullable final File baseDir) {
        this.baseDir = baseDir;
    }

    public FileResourceSet() {
        this(null);
    }

    public FileResourceSet(@Nullable final File baseDir, @NotNull final String... files) {
        this(baseDir);
        add(files);
    }

    public FileResourceSet(@Nullable final String baseDir, @NotNull final String... files) {
        this(new File(baseDir), files);
    }

    public void add(@NotNull final String... files) {
        for (@NotNull final String f : files) {
            add(new File(baseDir, f));
        }
    }

    public FileResourceSet addDir(@NotNull final String... dirs) {
        for (@NotNull final String d : dirs) {
            final File fullDir = new File(baseDir, d);
            add(new FileTreeResource(fullDir));
        }
        return this;
    }

    public ResourceAction<File> copyTo(@NotNull final String toDir) {
        return super.run(new CopyToFileAction(toDir, baseDir));
    }


    public ResourceAction<File> copyTo(@NotNull final File toDir) {
        return super.run(new CopyToFileAction(toDir, baseDir));
    }
}
